<template>
  <div>
    <div class="test">++{{id}}++
      <van-grid :column-num="6">
        <van-grid-item @click="component(item.name)" icon="gem-o" :text="item.text" v-for="(item,index) in components" :key="index"/>
      </van-grid>
      <!-- <Btn/> -->
      <component :receive='receive' :is="currentView"/>
    </div>
  </div>
</template>

<script>
import Btn from './btn.vue'
import Picture from './picture.vue'
import VuextestC from './vuextest.vue'
  export default {
    props: ['id'],
    created(){
      this.$store.dispatch('test').then(res=>{
        console.log(res)
      })
    },
    data() {
      return {
        currentView: 'Btn',
        components: [
          {name: 'Btn',text: '按钮'},
          {name: 'Picture',text: '图片'},
          {name: 'VuextestC',text: 'vuex'},
        ]
      }
    },
    components: {
      Btn,Picture,VuextestC
    },
    methods: {
      component(val) {
        this.currentView = val
      },
      receive(x) {
        console.log('我是父组件',x)
      }
    }
  }
</script>  
<style lang="less" scoped>

</style>
